{%  extends "base.html" %}

{% block site_name %}用户界面{% endblock %}
{% block header %}用户模式{% endblock %}
{% block left_body %}
        <ul class="nav flex-column nav-pills">
            <li class="nav-item">
                <a  class="nav-link active" href="/">转到主界面</a>
            </li>
          <li class="nav-item">
            <a class="nav-link" href="../">返回用户主界面</a>
          </li>
        </ul>
{% endblock %}

{% block right_body %}

{% if search==None %}

<form role="form" action="" method="get" class="form-inline">
    <div class="form-group">

        <label for="Bname">
            输入书名查询（可以不完整）
        </label>
        <input type="text" class="form-control" name="Bname"/>
    </div>
    <input type="hidden" name="p" value="1"/>
    <button type="submit" class="btn btn-primary">
        Submit
    </button>
</form>
{% endif %}

{% if search != None%}
<table class="table table-bordered">
  <thead>
  <tr class="table-active">
      <th>ISBN</th>
      <th>书名</th>
      <th>类别</th>
      <th>作者</th>
      <th>出版社</th>
      <th>价格</th>
      <th>剩余数量</th>
      <th>点击加入借阅列表</th>
  </tr>
  </thead>
{% for row in search %}
<tr class="table-success">
    <td>{{ row[0] }}</td>
    <td>{{ row[1] }}</td>
    <td>{{ row[3] }}</td>
    <td>{{ row[4] }}</td>
    <td>{{ row[5] }}</td>
    <td>{{ row[6] }}</td>
    <td>{{ row[7] }}</td>
    <td>
        <form role="form" action="/user/borrow/add/" method="get" class="form-inline">
            <input type="hidden" name="ISBN" value="{{ row[0] }}"/>

            <button type="submit" class="btn btn-primary {% if  row[7] ==0 %}disabled{%  endif %}">
                我要借书
            </button>
        </form>
    </td>
</tr>

{% endfor %}
</table>

<div>
<ul class="pagination">
    <li class="page-item"><a class="page-link" href="/user/search/?Bname={{ keyword }}&p={{ page-1 }}">Previous</a></li>
    <li class="page-item"><a class="page-link" href="/user/search/?Bname={{ keyword }}&p=1">1</a></li>
    <li class="page-item"><a class="page-link" href="/user/search/?Bname={{ keyword }}&p=2">2</a></li>
    <li class="page-item"><a class="page-link" href="/user/search/?Bname={{ keyword }}&p=3">3</a></li>
    <li class="page-item"><a class="page-link" href="/user/search/?Bname={{ keyword }}&p={{ page+1 }}">Next</a></li>
</ul>
</div>

<a href="/user/search/">我还要查询其他书</a>
{% endif %}


{% endblock %}